package com.linkage.educloud.ah.data;

import android.content.ContentUris;
import android.net.Uri;
import android.provider.BaseColumns;


public class Ws {

    public static final String AUTHORITY = "com.linkage.educloud.ah.ws";

    private Ws() {
    }

    public interface AccountColumns {

        /*用户账号*/
        String ACCOUNT_NAME = "account_name";
        /*密码*/
        String PASSWORD = "password";
        /*用户名*/
        String USER_NAME = "user_name";
        /*用户id*/
        String USER_ID = "user_id";
        /*手机号*/
        String PHONE = "phone";
        /*用户类型1:教师 2：学生 3：家长*/
        String USERTYPE = "user_type";
        /*账号类型：1.个人中心 2.校讯通，目前1可以用来标识注意用户*/
        String ORGIN = "orgin";
        /*用户头像*/
        String AVATAR = "avatar";
        /*年级id*/
        String GRADEID = "grade_id";
        /*积分*/
        String CREDITSCORE = "credit_score";
        /*积分有效期*/
        String CREDITSCORE_VILIDATE = "credit_score_vilidate";
        /*是否签到*/
        String ISSIGN = "is_sign";
        /*token*/
        String TOKEN = "token";
        /*登录状态1登录中 其他未登录*/
        String ISLOGINING = "is_login";
        /*最后登录的时间*/
        String LAST_LOGIN = "last_login";
    }

    public static final class AccountTable implements AccountColumns, BaseColumns {
        private AccountTable() {
        }

        public static final String PATH = "accounts";
        public static final String PATH_LAST_USER = "accountLastUser";
        public static final String PATH_DEFAULT_USER = "accountDefaultUser";
        /**
         * 此表的uri
         */
        public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/" + PATH);
        public static final Uri CONTENT_URI_LAST_USER = Uri.parse("content://" + AUTHORITY + "/" + PATH_LAST_USER);
        public static final Uri CONTENT_URI_DEFAULT_USER = Uri.parse("content://" + AUTHORITY + "/" + PATH_DEFAULT_USER);
        /**
         * MIME TYPE
         */
        public static final String CONTENT_TYPE = "vnd.android.cursor.dir/imps-accounts";
        public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/imps-accounts";

        public static final String TABLE_NAME = "accounts";
        public static final String CREATE_TABLE_SQL = "CREATE TABLE " + TABLE_NAME + "("
                + "_id INTEGER PRIMARY KEY,"
                + ACCOUNT_NAME + " TEXT,"
                + PASSWORD + " TEXT,"
                + USER_NAME + " TEXT,"
                + USER_ID + " INTEGER,"
                + USERTYPE + " INTEGER,"
                + GRADEID + " INTEGER,"
                + ORGIN + " INTEGER,"
                + PHONE + " TEXT,"
                + AVATAR + " TEXT,"
                + CREDITSCORE + " INTEGER,"
                + CREDITSCORE_VILIDATE + " TEXT,"
                + ISSIGN + " INTEGER,"
                + ISLOGINING + " INTEGER DEFAULT 0,"
                + LAST_LOGIN + " TEXT,"
                + TOKEN + " TEXT"
                + ");";
    }

    public interface ChildColumns {
        String ACCOUNT_NAME = "account_name";
        String ID = "id";
        String NAME = "name";
        String PARENTID = "parentid";
        String CLASSNAME = "classname";
        String CLASSID = "classid";
        String SCHOOL = "school";
        String AVATAR = "avatar";
        String GRADEID = "gradeid";
        String GRADENAME = "gradename";
        String DEFAULTCHILD = "default_child";
        String REMOTEID = "remoteid";
    }

    public static final class ChildTable implements ChildColumns, BaseColumns {

        public static final String TABLE_NAME = "childs";
        public static final String PATH = "childs";
        public static final String ACCOUNT_PATH = "account_childs";
        /**
         * 此表的uri
         */
        public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/" + PATH);
        public static final Uri CONTENT_URI_ACCOUNT = Uri.parse("content://" + AUTHORITY + "/" + ACCOUNT_PATH);

        /**
         * MIME TYPE
         */
        public static final String CONTENT_TYPE = "vnd.android.cursor.dir/imps-childs";
        public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/imps-childs";
        public static final String CREATE_TABLE_SQL = "CREATE TABLE " + TABLE_NAME + "("
                + "_id INTEGER PRIMARY KEY,"
                + ACCOUNT_NAME + " TEXT,"
                + ID + " INTEGER,"
                + NAME + " TEXT,"
                + PARENTID + " INTEGER,"
                + CLASSNAME + " TEXT,"
                + CLASSID + " INTEGER,"
                + SCHOOL + " TEXT,"
                + AVATAR + " TEXT,"
                + GRADEID + " INTEGER,"
                + GRADENAME + " TEXT,"
                + DEFAULTCHILD + " INTEGER,"
                + REMOTEID + " TEXT"
                + ");";
    }

    /**
     * 对话列<br>
     * 对话是指发生的交互动作,比如与某人的对话，这整个过程就是一个thread<br>
     */
    public interface ThreadColumns {


        String ACCOUNT_NAME = "account_name";

        /**
         * 消息id
         * <P>Type: INT</P>
         */
        String MSG_ID = "msg_id";

        /**
         * 好友ID /　群组ID
         * <P>Type: INT</P>
         */
        String BUDDY_ID = "buddy_id";

        /**
         * 消息内容
         * <P>Type: TEXT</P>
         */
        String MSG_BODY = "msg_body";

        /**
         * 收到消息时间
         * <P>Type: INT</P>
         */
        String MSG_RECEIVED_TIME = "msg_receive_time";

        /**
         * 消息发送的时间
         * <P>Type: INT</P>
         */
        String MSG_SENT_TIME = "msg_sent_time";

        /**
         * 未阅读数
         * <P>Type: INT</P>
         */
        String UNREAD_COUNT = "unread_count";

        /**
         * 发出消息的状态
         * <P>Type: INT</P>
         */
        String MSG_OUTBOUND_STATUS = "msg_outbound_status";

        /**
         * 接受的消息标志
         * <P>Type: INT</P>
         */
        String MSG_IS_INBOUND = "msg_is_inbound";

        /**
         * 消息类型
         * <P>Type: INT</P>
         * 图片，文本，音频
         */
        String MSG_TYPE = "msg_type";

        /**
         * 用户id
         */
        String USER_ID = "user_id";

        /**
         * 聊天类型
         * <p>Type:INT</p>
         * 群组，单聊
         */
        String CHAT_TYPE = "chat_type";
        /**
         * 用户区分家庭作业，班级，以及精彩资讯等和im聊天，并作为排序的依据置顶作业和班级，为0，班级为1，精彩资讯与im聊天为2//***
         * 班级0，空间1，家校2，系统通知3,资讯4，im聊天10
         */
        String THREAD_TYPE = "thread_type";

        String ORG_NAME = "org_name";
    }

    /**
     * 事件表<br>
     *
     * @author songpeng
     */
    public static final class ThreadTable implements BaseColumns, ThreadColumns {
        private ThreadTable() {
        }

        public static final String TABLE_NAME = "threads";
        /**
         * 此表的uri
         */
        public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/threads");

        public static final Uri CONTENT_URI_BY_BUDDY_ID = Uri.parse("content://" + AUTHORITY + "/threadByBuddyId");

        /**
         * MIME type
         */
        public static final String CONTENT_TYPE = "vnd.android.cursor.dir/imps-threads";

        public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/imps-threads";

        /**
         * 广播url
         */
        public static final String CONTENT_CHAGED = "com.linkage.educloud.ah.threadtable.changed";
        public static final String CREATE_TABLE_SQL = "CREATE TABLE " + TABLE_NAME + "("
                + "_id INTEGER PRIMARY KEY," + "account_name text,"
                + "msg_id INTEGER," + "buddy_id TEXT,"
                + "msg_body TEXT," + "msg_receive_time INTEGER DEFAULT 0,"
                + "msg_sent_time INTEGER DEFAULT 0,"
                + "unread_count INTEGER DEFAULT 0,"
                + "msg_outbound_status INTEGER DEFAULT 0,"
                + "msg_is_inbound INTEGER," + "msg_type INTEGER,"
                + "user_id INTEGER DEFAULT 0,"
                + "chat_type INTEGER INTEGER DEFAULT 0,"
                + "thread_type INTEGER DEFAULT 10,"
                + "org_name TEXT"
                + ");";
    }

    /**
     * 消息类型
     *
     * @author songpeng
     */
    public interface MessageType {

        /**
         * 发送消息
         */
        int OUTGOINT = 0;
        /**
         * 接收的消息
         */
        int INCOMING = 1;

        /**
         * 文本消息
         */
        int TYPE_MSG_TEXT = 1;

        /**
         * 音频消息
         */
        int TYPE_MSG_AUDIO = 2;

        /**
         * 图片消息
         */
        int TYPE_MSG_PIC = 3;


        int TYPE_MSG_HOMEWORK = 4;

        int TYPE_MSG_NOTICE = 5;
        int TYPE_MSG_JOB = 6;
        int TYPE_MSG_GRADE = 7;
        int TYPE_MSG_SAFE = 8;
        int TYPE_NEWS = 9;
        int TYPE_CLASS_SPACE = 10;
        int TYPE_SYSTEM = 11;
        int TYPE_SYLLABUS = 12;
        int TYPE_MSG_FILE = 13;
        int TYPE_JX = 14;
        int TYPE_TOPIC = 15;
        /**
         * 发送失败状态
         */
        int MSG_STATUS_ERROR = -1;

        /**
         * 待发送状态 ，尚未发送成功
         */
        int MSG_STATUS_WAITING = 0;

        /**
         * 已发送状态 ，发送成功
         */
        int MSG_STATUS_SENT = 1;

        /**
         * 已阅读状态
         */
        int MSG_STATUS_ARRIVED = 2;

        /**
         * 已阅读状态
         */
        int MSG_STATUS_READED = 3;

        String MSG_TYPE_All = "('1','2','3','4','5')";

        String MSG_TYPE_CHAT = "('1','2','3')";

        String MSG_TYPE_HOME_NOTICE = "('4','5','6','7','8')";


    }

    /**
     * 消息列
     *
     * @author songpeng
     */
    public interface MessageColumns {

        String ACCOUNT_NAME = "account_name";

        /**
         * 好友ID /　群组ID
         * <P>Type: INT</P>
         */
        String BUDDY_ID = "buddy_id";

        /**
         * 消息内容
         * <P>Type: TEXT</P>
         */
        String BODY = "body";

        /**
         * 接受的消息标志
         * <P>Type: INT</P>
         */
        String IS_INBOUND = "is_inbound";
        /**
         * 语音聊天时长
         */
        String DURATION = "duration";

        /**
         * 是否阅读标志
         * <P>Type: INT</P>
         */
        String IS_READ = "is_read";

        /**
         * 发出的消息的状态 是否发出 是否被读etc -1 发送失， 0 未发送成功 ，  1成功未接受，  2已读
         * <P>Type: INT</P>
         */
        String OUTBOUND_STATUS = "outbound_status";

        /**
         * 收到时间
         * <P>Type: INT</P>
         */
        String RECEIVED_TIME = "received_time";

        /**
         * 发送者ID
         * <P>Type: INT</P>
         */
        String SENDER_ID = "sender_id";

        /**
         * 发送时间
         * <P>Type: INT</P>
         */
        String SENT_TIME = "sent_time";

        /**
         * 消息类型
         * <P>Type: INT</P>
         * 图片，音频，文本。
         */
        String TYPE = "type";

        /**
         * 发送者设备id
         * <P>Type: INT</P>
         */
        String SENDER_DEVICE_ID = "sender_device_id";

        /**
         * 聊天类型
         * <p>TYPE: INTEGER</p>
         * 群组，单聊
         */
        String CHAT_TYPE = "chat_type";
        /**
         * 用户区分家庭作业，班级，以及精彩资讯等和im聊天，并作为排序的依据置顶作业和班级，作业为0，班级为1，精彩资讯与im聊天为2
         */
        String THREAD_TYPE = "thread_type";

        //String USER_TYPE = "user_type";

    }

    /**
     * 存储消息的表<br>
     *
     * @author songpeng
     */
    public static final class MessageTable implements BaseColumns, MessageColumns {

        private MessageTable() {
        }

        public static final String TABLE_NAME = "messages";
        /**
         * 此表的uri
         */
        public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/messages");

        /**
         * Content URL
         */
        public static final Uri CONTENT_URI_MESSAGES_BY_BUDDY_ID = Uri
                .parse("content://" + AUTHORITY + "/messagesByBuddyId");

        /**
         * Group Content URL
         */
        public static final Uri CONTENT_URI_MESSAGES_BY_GROUP_ID = Uri
                .parse("content://" + AUTHORITY + "/messagesByGroupId");

        /**
         * MIME TYPE
         */
        public static final String CONTENT_TYPE = "vnd.android.cursor.dir/imps-messages";
        public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/imps-messages";

        /**
         * 获得通过好友的id获得聊天记录的uri
         *
         * @param buddyId
         * @return
         */
        public static final Uri getContentUriByBuddyId(long buddyId) {
            Uri.Builder builder = CONTENT_URI_MESSAGES_BY_BUDDY_ID.buildUpon();
            ContentUris.appendId(builder, buddyId);
            return builder.build();
        }

        public static final String CREATE_TABLE_SQL = "CREATE TABLE " + TABLE_NAME + "("
                + "_id INTEGER PRIMARY KEY," + "account_name text,"
                + "buddy_id INTEGER," + "body TEXT,"
                + "is_inbound INTEGER," + "is_read INTEGER,"
                + "outbound_status INTEGER,"
                + "duration INTEGER,"
                + "received_time INTEGER DEFAULT 0," + "sender_id INTEGER,"
                + "sent_time INTEGER," + "type INTEGER,"
                + "chat_type INTEGER INTEGER DEFAULT 0,"
                + "thread_type INTEGER DEFAULT 5" + ");";
    }
    public interface GroupColumns {
        String ACCOUNT_NAME = "account_name";
        /**
         * 群组id
         */
        String ID = "id";
        /**
         * 聊天id
         */
        String REMOTEID = "remoteId";
        String GROUP_NAME = "group_name";
        String GROUP_AVATAR = "group_avatar";
        String GROUP_NUM = "group_num";
        /**
         * 组群描述介绍
         */
        String DESC = "desc";
        /**
         * 是否开通v网短号
         */
        String ISOPEN_SHORTDN = "isopen_shortdn";
        String TEACHER_NUM = "teacher_num";
        String PARENT_NUM = "parent_num";
        String STUDENT_NUM = "student_num";
        /**
         * 群组类型 0班级群，1自建群，2临时群
         * <p>TYPE:INT</p>
         */
        String GROUP_TYPE = "group_type";
        /**
         * 当前用户在群组内的角色
         * 群主/创建者、成员
         */
        String ROLE = "role";
        String SCHOOL = "school";
        String CLASSNAME = "classname";
    }

    public static final class GroupTable implements BaseColumns, GroupColumns {
        private GroupTable() {
        }
        public static final String PATH = "groups";
        public static final String TABLE_NAME = "groups";
        public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/" + PATH);
        public static final String CONTENT_TYPE = "vnd.android.cursor.dir/imps-groups";
        public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/imps-groups";
        public static final String CREATE_TABLE_SQL = "CREATE TABLE " + TABLE_NAME + "("
                + "_id INTEGER PRIMARY KEY,"
                + ACCOUNT_NAME + " TEXT,"
                + ID + " INTEGER,"
                + REMOTEID + " TEXT,"
                + GROUP_NAME + " TEXT,"
                + GROUP_AVATAR + " TEXT,"
                + GROUP_NUM + " INTEGER,"
                + GROUP_TYPE + " INTEGER,"
                + DESC + " TEXT,"
                + ISOPEN_SHORTDN + " INTEGER,"
                + TEACHER_NUM + " INTEGER,"
                + PARENT_NUM + " INTEGER,"
                + STUDENT_NUM + " INTEGER,"
                + ROLE + " INTEGER,"
                + SCHOOL + " TEXT,"
                + CLASSNAME + " TEXT"
                + ");";
    }

    public interface ContactColumns {
        String ACCOUNT_NAME = "account_name";
        String ID = "id";
        String REMOTEID = "remoteId";
        String NAME = "name";
        String FIRSTNAME = "firstname";
        String TYPE = "type";
        String GROUP_ID = "group_id";
        String GROUP_NAME = "group_name";
        String AVATAR_URL = "avatar_url";
        /**
         * 手机号
         */
        String PHONE = "phone";
        /**
         * 短号
         */
        String SHORT_DN = "short_dn";
        /**
         * 是否公开手机号
         */
        String ISOPENPHONE = "isopenphone";
        String CLASS_NAME = "class_name";
        String SCHOOL_NAME = "school_name";
        String STUDENT_ID = "student_id";
        String STUDENT_NAME = "student_name";
        String STUDENT_RELATIVE = "student_relative";
        /**
         * 是否在线
         */
        String ONLINE = "online";
        /**
         * 是否可邀请，从没使用客户端的用户可以被邀请
         */
        String INVITE = "invite";
        /**
         * 用户订购状态
         */
        String STATUS = "status";
    }

    public static final class ContactTable implements BaseColumns, ContactColumns {
        private ContactTable() {
        }

        public static final int TYPE_FRIEND = 1;
        public static final int TYPE_CLASS = 2;

        public static final String PATH = "contacts";

        public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/" + PATH);
        public static final String CONTENT_TYPE = "vnd.android.cursor.dir/imps-contacts";
        public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/imps-contacts";

        public static final String TABLE_NAME = "contacts";
        public static final String CREATE_TABLE_SQL = "CREATE TABLE " + TABLE_NAME + "("
                + "_id INTEGER PRIMARY KEY,"
                + ACCOUNT_NAME + " TEXT,"
                + REMOTEID + " INTEGER,"
                + ID + " INTEGER,"
                + NAME + " TEXT,"
                + FIRSTNAME + " TEXT,"
                + TYPE + " INTEGER,"
                + GROUP_ID + " INTEGER,"
                + GROUP_NAME + " TEXT,"
                + AVATAR_URL + " TEXT,"
                + PHONE + " TEXT,"
                + SHORT_DN + " INTEGER,"
                + ISOPENPHONE + " INTEGER,"
                + CLASS_NAME + " TEXT,"
                + SCHOOL_NAME + " TEXT,"
                + STUDENT_ID + " INTEGER,"
                + STUDENT_NAME + " TEXT,"
                + STUDENT_RELATIVE + " TEXT,"
                + ONLINE + " INTEGER,"
                + INVITE + " INTEGER,"
                + STATUS + " TEXT"
                + ");";
    }
}

